import sys

from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtWidgets import QApplication, QMessageBox
from pyqt5_plugins.examplebutton import QtWidgets

from ui.redwin import Ui_MainWindow

class red(QtWidgets.QMainWindow,Ui_MainWindow):
    value_signal = pyqtSignal(str)
    def __init__(self):
        super(red,self).__init__()
        self.setupUi(self)
        self.setWindowFlags(Qt.WindowMinimizeButtonHint)
        self.InitSlit()
        self.fangshi = ''

    def InitSlit(self):
        self.pushButton.clicked.connect(self.PTF)
        self.pushButton_2.clicked.connect(self.PTG)
        self.pushButton_3.clicked.connect(self.SDP)
        self.pushButton_4.clicked.connect(self.SUP)
        self.pushButton_5.clicked.connect(self.RSC)
        self.pushButton_6.clicked.connect(self.PUN)
        self.pushButton_7.clicked.connect(self.KO_)
        self.pushButton_8.clicked.connect(self.WDR)
        self.pushButton_9.clicked.connect(self.DSQ)
        self.pushButton_10.clicked.connect(self.WTW)
        self.pushButton_11.clicked.connect(self.DRAW)
        self.pushButton_12.clicked.connect(self.guan)

    def PTF(self):
        self.fangshi = 'PTF'
        QMessageBox.information(self, "提示", "获胜方式为{}".format(self.fangshi), QMessageBox.Ok)

    def PTG(self):
        self.fangshi = 'PTG'
        QMessageBox.information(self, "提示", "获胜方式为{}".format(self.fangshi), QMessageBox.Ok)

    def SDP(self):
        self.fangshi = 'SDP'
        QMessageBox.information(self, "提示", "获胜方式为{}".format(self.fangshi), QMessageBox.Ok)

    def SUP(self):
        self.fangshi = 'SUP'
        QMessageBox.information(self, "提示", "获胜方式为{}".format(self.fangshi), QMessageBox.Ok)

    def RSC(self):
        self.fangshi = 'RSC'
        QMessageBox.information(self, "提示", "获胜方式为{}".format(self.fangshi), QMessageBox.Ok)

    def PUN(self):
        self.fangshi = 'PUN'
        QMessageBox.information(self, "提示", "获胜方式为{}".format(self.fangshi), QMessageBox.Ok)

    def KO_(self):
        self.fangshi = 'k.O'
        QMessageBox.information(self, "提示", "获胜方式为{}".format(self.fangshi), QMessageBox.Ok)

    def WDR(self):
        self.fangshi = 'WDR'
        QMessageBox.information(self, "提示", "获胜方式为{}".format(self.fangshi), QMessageBox.Ok)

    def DSQ(self):
        self.fangshi = 'DSQ'
        QMessageBox.information(self, "提示", "获胜方式为{}".format(self.fangshi), QMessageBox.Ok)

    def WTW(self):
        self.fangshi = 'WTW'
        QMessageBox.information(self, "提示", "获胜方式为{}".format(self.fangshi), QMessageBox.Ok)

    def DRAW(self):
        self.fangshi = 'DRAW'
        QMessageBox.information(self, "提示", "获胜方式为{}".format(self.fangshi), QMessageBox.Ok)

    def guan(self):
        self.close()
        self.value_signal.emit(self.fangshi)

if __name__ == '__main__':
    QApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
    # 适应高DPI设备
    QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    # 解决图片在不同分辨率显示模糊问题
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = red()
    MainWindow.show()
    sys.exit(app.exec_())
